/**
 ***********************************************************************
 * Program name: MailDateBuilder.java<br>
 * Program description: TODO<br>
 * Author: sugen<br>
 * Revision history:1.0<br>
 * <br>
 * Description of Change	Programmer		Date<br>
 * ---------------------    ----------      ----<br>
 * Initial creation			Su Gen		   2011-3-9 <br>
 * <br>
 * Copyright (c) 2011 by SUGEN ALL RIGHTS RESERVED<br>
 ************************************************************************
 */
package com.mail;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javolution.util.FastMap;


import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.common.DBCon;
import com.mail.EmailFormatBuilder;

public class MailDataBuilder  {
	private static Logger log = LogManager.getLogger(MailDataBuilder.class);
	
	public MailDataBuilder() {
		super();
	}

	public String buildMailData(String sql) throws Exception{
		DBCon dbcon= new DBCon();
		ResultSet rs=dbcon.executeQuery(sql);
		StringBuffer output;
		if(rs!=null){
			List list=new ArrayList();
			String [] header={
				"Customer Code",
				"Error Info"
			};
			while(rs.next()){
				Map map=new HashMap();
				map.put("Customer Code", rs.getString("customerCode"));
				map.put("Error Info", "No registration in ODC.");
				list.add(map);
			}
			output=EmailFormatBuilder.buildHtml(header, list);
			return output.toString();
		}else{
			return null;
		}
	}
	
}
